package com.xintoucloud.gsv.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.xintoucloud.gsv.entity.SupervisionReply;

public interface SupervisionReplyMapper {

	//查询所有督办回复信息
	@Select("select * from t_supervision_reply")
	@Results({	
		@Result(property="superVision",column="svid",one=@One(select="com.xintoucloud.gsv.mapper.SuperVisionMapper.getSuperVision")),
		@Result(property="svrs",column="rsid",one=@One(select="com.xintoucloud.gsv.mapper.SupervisionReplyStateMapper.getSvrs"))
	})
	List<SupervisionReply> allsvr();
	
	//查询所有督办回复信息
	@Select("select * from t_supervision_reply where svid=#{svid}")
	@Results({	
		@Result(property="superVision",column="svid",one=@One(select="com.xintoucloud.gsv.mapper.SuperVisionMapper.getSuperVision")),
		@Result(property="svrs",column="rsid",one=@One(select="com.xintoucloud.gsv.mapper.SupervisionReplyStateMapper.getSvrs"))
	})
	List<SupervisionReply> theSvidsvr(int svid);
	
	
	
	/*
	 * 为一个督办事件添加一条回复信息记录
	 * 未添加详细内容
	 */	
	@Insert("insert into t_supervision_reply(svid,director,dutyidea,rsid) values(#{superVision.svid},#{director},#{dutyidea},#{svrs.rsid})")
	void save(SupervisionReply svr);
	
	/*
	 * 部门专员添加回复内容(没有用到 部门专员添加回复内容用的save方法)
	 */
	@Update("update t_supervision_reply set director=#{director},rsid=#{rsid} where rid=#{rid}")
	void dirupdate(@Param("director")String director,@Param("rid")int rid,@Param("rsid")int rsid);
	
	/*
	 * 部门正职添加审核回复
	 */
	@Update("update t_supervision_reply set dutyidea=#{dutyidea},rsid=#{rsid} where rid=#{rid}")
	void dutyupdate(@Param("dutyidea")String dutyidea,@Param("rid")int rid,@Param("rsid")int rsid);
	
	/*
	 * 分管领导添加审核回复
	 */
	@Update("update t_supervision_reply set leaderidea=#{leaderidea},rsid=#{rsid} where rid=#{rid}")
	void leaderupdate(@Param("leaderidea")String leaderidea,@Param("rid")int rid,@Param("rsid")int rsid);
	
	/*
	 * 分管领导添加审核回复
	 */
	@Update("update t_supervision_reply set visionidea=#{visionidea},rsid=#{rsid} where rid=#{rid}")
	void visionupdate(@Param("visionidea")String visionidea,@Param("rid")int rid,@Param("rsid")int rsid);
	
}
